package utl.mofen.servlet;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import utl.mofen.utils.FileUtil;


public class Util {
	public static String pageFileName(HttpServletRequest _request)
	{
		String url = _request.getRequestURI();
		return FileUtil.extractFileName(url);
	}
	
	public static String request2JSon(HttpServletRequest _request)
	{
		String jsonString = "";
		
	
		Enumeration<String> params = _request.getParameterNames();
		String name ="";
		while(params.hasMoreElements())
		{			
			name = params.nextElement();
			jsonString = jsonString + "\""+ name + "\"=\"" + _request.getParameter(name) + "\",";
		};
		if (jsonString.length()!=0)
		{
			jsonString = "{" + jsonString.substring(0, jsonString.length() - 1) + "}";
		}
		return jsonString;		
	}
}
